// 存放修改state属性的方法
export default {
    // 收藏
    shoucang(state, i) {
        if (state.sp[i-1].sc) {
            state.sp[i-1].sc = false
            for (let j = 0; j < state.sc.length; j++) {
                if (state.sc[j].id == i) {
                    state.sc.splice(j, 1)
                }
            }
        } else {
            state.sp[i-1].sc = true
            state.sc.push(state.sp[i-1])
        }
    },
    // 提交
    tijiao(state) {
        if (state.tijiaodd[0] == undefined) {
            return
        } else {
            for (let i = 0; i < state.tijiaodd.length; i++) {
                state.tijiaodd[i].fh = '待付款'
            }
            let arr = state.tijiaodd.concat()
            arr.sj = new Date().toLocaleDateString();
            arr.ddh = 10000000 + state.dingdan.length
            state.dingdan.push(arr)
            arr = []
        }
    },
    // 购买
    tijiao2(state) {
        for (let i = 0; i < state.tijiaodd.length; i++) {
            state.tijiaodd[i].fh = '待发货'
        }
        let arr = state.tijiaodd.concat()
        arr.sj = new Date().toLocaleDateString();
        state.dingdan.splice(length - 1, 1)
        arr.ddh = 10000000 + state.dingdan.length
        state.dingdan.push(arr)
        let time = setTimeout(function () {
            state.tijiaodd = [];
        }, 1000);
    },
    // 默认地址
    mr(state,i){
        state.mrdz=i;
    },
    // 勾选收货地址
    myshdz(state,i){
        state.shdz=state.dz[i]
    },
    // 删除地址
    remo(state,i){
        state.dz.splice(i,1)
    },
    // 添加地址
    add(state,obj){
        if(obj.name){
        state.dz.push(obj)
        }else{
          return
        }
    }
}